using System;
using System.Collections.Generic;
using System.Text;

namespace CardSystemUtils
{
    public class Validator
    {
        public static bool CheckLuhn(byte[] digits)
        {
            int sum = 0;
            bool alt = false;
            for (int i = digits.Length - 1; i >= 0; i--)
            {
                if (alt)
                {
                    digits[i] *= 2;
                    if (digits[i] > 9) digits[i] -= 9;
                }
                sum += digits[i];
                alt = !alt;
            }
            return sum % 10 == 0;
        } 
    }
}
